/**
 * BrickMemento
 * 
 * Version 1.0
 *
 * Nov 29th, 2009
 * 
 * Copyright (c) 2009 Oksana Yaremchuk 
 */
import java.io.Serializable;
/**
 * BrickMemento
 * @author Oksana Yaremchuk
 *
 */
//Comparable<BrickMemento>, commenting
public class BrickMemento implements Memento, Serializable, Cloneable
{
	/**serialVersionUID needed for managing Serializable interface*/
	private static final long serialVersionUID = 1L;

	private double height;
	private double width;
	private double length;
	
	
	
	public BrickMemento(double height, double width, double length) 
	{	
		this.height=height;
		this.width=width;
		this.length=length;		
	
	}//end constructor.


	/**
	 * get the height 
	 * @return the height of the state
	 */
	
	public double getHeight() 
	{
	
		return height;
	}


	/**
	 * get the length 
	 * @return the length of the state
	 */
	public double getLength() {
	
		return length;
	}


	/**
	 * get the width 
	 * @return the width of the state
	 */
	public double getWidth() {
		
		return width;
	}
	
	
	/* (non-Javadoc)
	 * @see java.lang.Object#clone()
	 */
	@Override
	protected Object clone() throws CloneNotSupportedException {
		return super.clone();
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object other) {
		
        if(other==null) return false;
		
		Class otherClass = other.getClass();
		
		Class thisClass = this.getClass();
		
		if(!thisClass.equals(otherClass)) return false;
		
		BrickMemento otherBrickMemento = (BrickMemento) other;                   //a safe cast
		
		return otherBrickMemento.height==this.height &&
		       otherBrickMemento.width== this.width &&
		       otherBrickMemento.length==this.length;
	}
	
	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return toString().hashCode();
	}
	
/*	--- commenting out for now - Sophia
    public int compareTo(BrickMemento bm){
		
		if(this.height < bm.height ||
				this.width < bm.width ||
					this.length < bm.length)
		{
			return -1;
			
		}
		else if(this.height > bm.height ||
				     this.width > bm.width ||
				          this.length > bm.length)
		{
			return 1;
		}
		
		return 0;
	}
*/


    /**
     * to String
     */
    public String toString() {
        return "Height = " + this.height + "\nWidth = " + this.width + 
            "\nLength = " + this.length;
    }
	
	
}//end of class
